<?php
    ob_start();
    include('session.inc');
    require_once('funct.inc');
    include 'html_style.php';
    include 'color_style.php';
    include LANGUAGE;
    include '../plugins/order/classOrderService.inc.php';
    //--------------------MODUL LOGS--------------------------------------
    if (file_exists("modules/logs/logs.inc"))
	    require_once("modules/logs/logs.inc");
            //--------------------------------------------------------------------
            //******************************MODUL TOP_USER***********************
            //**********************************************************************
            //**********************************************************************
            if(file_exists("modules/top_user/functions_top.inc")) 
            {
                     require_once('modules/top_user/functions_top.inc');
            }
            //**********************************************************************
            //**********************************************************************
            //**********************************************************************
            //******************************MODUL TOP_PRODUCT***********************
            //**********************************************************************
            //**********************************************************************
            if(file_exists("modules/top_products/functions_top.inc")) 
            {
                     require_once('modules/top_products/functions_top.inc');
            }
            //**********************************************************************
            //**********************************************************************
            //**********************************************************************
    if(!GetAdminID($ID)){echo LOGIN_ERR;exit;}
    if(!Right_Check(2)){header('Location:error.php');exit;}
    
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <?php echo '<meta http-equiv="Content-Type" content="text/html; charset='._CHARSET_.';">'; ?>

    <?php
        print "
            <script language=\"JavaScript\">
                <!--
                    function OpenPage(id, count){
                        var ComletPageName= \"show_product_detail.php\" + \"?ID=\" + id + \"&amp;Count=\" + count;
                        window.close(\"ShopBasketProductDetail\");
                        window.open(ComletPageName,\"ShopBasketProductDetail\",\"width=700px,height=300px,location=no,directories=no,menubar=no,resizeable=yes,status=no,toolbar=no,scrollbars=yes\");
                    }
                //-->
            </script>
        ";
    ?>

</head>
<?php

print "<body bgcolor=\"".Background_Color."\">";

require_once('OpenDB.inc');
require_once('functs.inc');
do
{
    if (!OpenDB()){echo OPEN_DB_ERR; break;}

    if($_REQUEST["PageQuanter"]=="")
       $PageNo=$_REQUEST["PageNo"];
    else
       $PageNo=$_REQUEST["PageNo"]-1;

    if($PageNo=="" || $PageNo==-1) $PageNo=0;
 //Definicie tovarov=================================
    $ItemsOnPage = ITEMSONPAGE;
    $ShowQvantumPage = SHOWQVANTUMPAGE;
 //===================================================
    $ActualQvantumPage=$_REQUEST["ActualQvantumPage"];
    if($ActualQvantumPage=="")$ActualQvantumPage = 0;

    $Logged_Admin   =$_SESSION['admin'];
    $index=0;
    $roll_show="/";

    $F_Surname      = $_REQUEST["F_Surname"];
    $F_Organisation = $_REQUEST["F_Organisation"];
    $F_ICO          = $_REQUEST["F_ICO"];

	

    $events=$_REQUEST["events"];
    switch($events) {
           case 'delete_order':      if (!Order_Is_Unread($_REQUEST["Ch_ID"])){
                                         if ($_REQUEST["GrantDelete"]!="YES")
                                            print"
                                                <center>
                                                    <table border=\"1\" bgcolor=\"".BACKGROUND_IN_TABLE."\">
                                                        <tr>
                                                            <td>
	                                                             ".O_VYMAZANIE.":".Get_Order_NO($_REQUEST["Ch_ID"])." ?
	                                                             <center>
																 <form action=\"order_management.php\" target=\"place\" method=\"post\">
                                                                    <input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />
                                                                    <input type=\"hidden\" name=\"events\" value=\"delete_order\" />
                                                                    <input type=\"hidden\" name=\"Ch_ID\" value=\"".$_REQUEST["Ch_ID"]."\" />
                                                                    <input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />
                                                                    <input type=\"hidden\" name=\"GrantDelete\" value=\"YES\" />
                                                                    <input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\" />
                                                                    <input type=\"hidden\" value=\"".$F_Organisation."\" name=\"F_Organisation\" />
                                                                    <input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />
                                                                    <input type=\"submit\" value='".O_ANO."' style=\"width :100px; background-color: ".BUTTON_ON_OUT.";\"
											                            onmouseover=\"this.style.backgroundColor='".BTN_IN_TABLE."'; this.style.fontWeight='bold';\";
											                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
                                                                </form>
																</center>
																<center>
                                                                <form action=\"order_management.php\" target=\"place\" method=\"post\">
                                                                    <input type=\"hidden\" value=\"".$ActualQvantumPage."\" NAME=\"ActualQvantumPage\" />
                                                                    <input type=\"hidden\" name=\"events\" value=\"show_order\" />
                                                                    <input type=\"hidden\" name=\"Ch_ID\" value=\"".$_REQUEST["Ch_ID"]."\" />
                                                                    <input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />
                                                                    <input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\" />
                                                                    <input type=\"hidden\" value=\"".$F_Organisation."\" NAME=\"F_Organisation\" />
                                                                    <input type=\"hidden\" value=\"".$F_ICO."\" NAME=\"F_ICO\" />
                                                                    <input type=\"submit\" value='".O_NIE."' style=\"width :100px; background-color: ".BUTTON_ON_OUT.";\"
											                            onmouseover=\"this.style.backgroundColor='".BTN_IN_TABLE."'; this.style.fontWeight='bold';\";
											                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
                                                                </form>
																</center>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </center>
                                            ";
                                        else{
                                             //---------------------------------------------------------------------
                                          	 //-------------------------MODUL ORDER_ARCHIVE-------------------------
                                          	 if (file_exists('modules/order_archive/order_archive.inc')){
	                                          	 require_once 'modules/order_archive/order_archive.inc';
	                                          	 Order_Archive_Insert($_REQUEST["Ch_ID"]);
	                                          	 //break;
                                          	 }
                                          	 //---------------------------------------------------------------------
                                          	 
											 ///-------------------Funkcia modulu LOGS--------------------------------
											 if (file_exists('modules/logs/logs.inc')){	                                             
	                                             Log_Insert("Vymazana objednavka", $_REQUEST["Ch_ID"], $ID);
	                                         }
											 ///----------------------------------------------------------------------
											 SQL_Delete_Order($_REQUEST["Ch_ID"]);
                                        }
                                        
									}else{
                                        print "<script language=\"JavaScript\">
                                            <!--
                                            window.alert(\"".O_ALERT_NIE_JE_MOZNE_VAMAZAT_NECITANU_OBJEDNAVKU."\");
                                            //-->
                                         </script>";
                                    }break;
           case 'show_order':       $roll_show = rutine_menu($_REQUEST["roll_show"],$_REQUEST["Ch_ID"]);
                                    if  (Order_Is_Unread($_REQUEST["Ch_ID"])) Order_Set_AsRead($_REQUEST["Ch_ID"]);
                                    //$roll_edit=$_REQUEST["roll_edit"];
                                    break;
           case 'ready_product':    Change_Product_Ready_Status($_REQUEST["RTE_ID"]);
                                    $roll_show = rutine_menu($_REQUEST["roll_show"],$_REQUEST["Ch_ID"]);
                                    break;
           case 'confirm_order':	
                                    $roll_show = rutine_menu($_REQUEST["roll_show"],0);
                                    if (!Order_Is_Unread($_REQUEST["Ch_ID"])){
                                            if (Order_Is_Confirm($_REQUEST["Ch_ID"]))
                                            {
                                                Order_Set_No_Confirm($_REQUEST["Ch_ID"]);
                                                ///----------------------------------------------------------------------
                                                ///-------------------Funkcia modulu LOGS--------------------------------  
                                                if (file_exists("modules/logs/logs.php"))                                                                               
                                                        Log_Insert("Obj. oznacena ako NEpotvrdena", $_REQUEST["Ch_ID"], $ID);
                                                ///----------------------------------------------------------------------
                                                ///----------------------------------------------------------------------						
                                                //******************************MODUL TOP_user***********************
                                                //**********************************************************************
                                                if(file_exists("modules/top_user/functions_top.inc")) 
                                                {
                                                        TopUserSearchInfo($ID_User,$TotalSum,$_REQUEST["Ch_ID"],PAYER_VAT);
                                                        TopUserUnset($ID_User,$TotalSum);
                                                }
                                                //**********************************************************************
                                                //**********************************************************************
                                                //******************************MODUL TOP_PRODUCT***********************
                                                //**********************************************************************
                                                //**********************************************************************
                                                if(file_exists("modules/top_products/functions_top.inc")) 
                                                {
                                                        TopProdUnset($_REQUEST["Ch_ID"]);
                                                }
                                                //**********************************************************************                                                
                                            }
	                                    else{
	                                        Order_Set_Confirm($_REQUEST["Ch_ID"]);
                                                ///----------------------------------------------------------------------
                                                ///-------------------Funkcia modulu LOGS--------------------------------  
                                                if (file_exists("modules/logs/logs.php"))                                                                                   
                                                        Log_Insert("Obj. oznacena ako potvrdena", $_REQUEST["Ch_ID"], $ID);
                                                ///----------------------------------------------------------------------
                                                ///----------------------------------------------------------------------				
                                                //******************************MODUL TOP_user***********************
                                                //**********************************************************************
                                                if(file_exists("modules/top_user/functions_top.inc")) 
                                                {
                                                        TopUserSearchInfo($ID_User,$TotalSum,$_REQUEST["Ch_ID"],PAYER_VAT);
                                                        TopUserInsert($ID_User,$TotalSum);
                                                }
                                                //**********************************************************************
                                                //**********************************************************************
                                                //******************************MODUL TOP_PRODUCT***********************
                                                //**********************************************************************
                                                //**********************************************************************
                                                if(file_exists("modules/top_products/functions_top.inc")) 
                                                {
                                                        TopProdInsert($_REQUEST["Ch_ID"]);
                                                }
                                                //**********************************************************************
                                                //**********************************************************************
                                                //**********************************************************************
                                                //----------------------------------------------------------------------
                                                //******************************MODUL INVOICE***************************
                                                //**********************************************************************
                                                //**********************************************************************
                                                if(file_exists("modules/invoice/invoice.inc")) 
                                                {
                                                         require_once('modules/invoice/invoice.inc');
                                                         Invoice_Insert($_REQUEST["Ch_ID"]);
                                                }
                                                //**********************************************************************
                                                }
	                                }
	                                else{
	                                	print "<script language=\"JavaScript\">
                                            <!--
                                            window.alert(\"".O_ALERT."\");
                                            //-->
                                         </script>";
                                    }
                                    break;
           default:break;
    }

    print("<center><b>".O_TITULOK."</b></center>");

    //**************************************************************************
    //
    //Zobrazenie komponentov pre vyhladavanie
    //
    //**************************************************************************

    if ($F_Surname=="" and $F_Organisation=="" and $F_ICO=="")
            print"
                    <center>
                    <table style=\"border:1px solid black;\">
                            <tr>
                                    <td>
                                            <form action=\"order_management.php\" target=\"place\" method=\"post\">
                                                    ".O_PRIEZVISKO.":
                                                    <input type=\"text\" name=\"F_Surname\">
                                                    <input type=\"submit\" value=\"".O_VYHLADAJ."\" style=\"width :70px; background-color: ".BUTTON_ON_OUT.";\"
                                                        onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                                                        onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
                                            </form>
                                    </td>
                                    <td>
                                            <form action=\"order_management.php\" target=\"place\" method=\"post\">
                                                    ".O_ORGANIZACIA.":
                                                    <input type=\"text\" name=\"F_Organisation\">
                                                    <input type=\"submit\" value=\"".O_VYHLADAJ."\" style=\"width :70px; background-color: ".BUTTON_ON_OUT.";\"
                                                        onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                                                        onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
                                            </form>
                                    </td>
                                    <td>
                                            <form action=\"order_management.php\" target=\"place\" method=\"post\">
                                                    ".O_ICO.":
                                                    <input type=\"text\" name=\"F_ICO\">
                                                    <input type=\"submit\" value=\"".O_VYHLADAJ."\" style=\"width :70px; background-color: ".BUTTON_ON_OUT.";\"
                                                        onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                                                        onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
                                            </form>
                                    </td>
                            </tr>
                    </table>
                        </center>";
        else
                print"
                    <center>
                    <table style=\"border:1px solid black;\">
                            <tr>
                                    <td>
                                            <form action=\"order_management.php\" target=\"place\" method=\"post\">
                                                    <input type=\"submit\" value=\"".O_VZRUSIT_VYHLADANIE."\" style=\"width=280px; background-color: ".BUTTON_ON_OUT.";\"
                                                        onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                                                        onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />
                                            </form>
                                    </td>
                            </tr>
                    </table>
                        </center>";

    //**************************************************************************
    //
    //Vytvorenie menu pre vyber zobrazovanej stranky (rozdelenie zobrazovane hotovaru) - ulozene hore
    //
    //**************************************************************************

    if ($F_Surname!="") $sql_psel= "SELECT COUNT(*) FROM order_heads WHERE OH_Surname LIKE '%".$F_Surname."%'";
    if ($F_Organisation!="") $sql_psel= "SELECT COUNT(*) FROM order_heads WHERE OH_Organisation LIKE '%".$F_Organisation."%'";
    if ($F_ICO!="") $sql_psel= "SELECT COUNT(*) FROM order_heads WHERE OH_ICO='".$F_ICO."'";
    if ($F_Surname=="" and $F_Organisation=="" and $F_ICO=="")
            $sql_psel= "SELECT COUNT(*) FROM order_heads";
    $sql_array_adm = mysql_fetch_row(mysql_query($sql_psel));
    if($sql_array_adm[0]/$ItemsOnPage==($PageNo)) $PageNo--;
    if($sql_array_adm[0]/$ItemsOnPage<=$ActualQvantumPage) $ActualQvantumPage=$ActualQvantumPage-$ShowQvantumPage;

    if (($sql_array_adm[0])==0){
           print "<br><center><b>".O_SEARCH_ERR."</b></center>";
           break;
      }
    do{
      if (($sql_array_adm[0]/$ItemsOnPage)<=1) break;
       print"<CENTER><table style=\"position:relative;  top:5px;\"><tr>";
// Podmienka prvej >>>> --------------------------------------------------------------------
      if(($sql_array_adm[0]/$ItemsOnPage>$ShowQvantumPage) and ($ActualQvantumPage-$ShowQvantumPage>=0)){
             print "<td>";
             print "<form  action=\"order_management.php\" target=\"place\" method=\"post\">";
             if($sql_array_adm[0]>$ShowQvantumPage)
               print "<input type=\"submit\" value=\"<<<\"  style=\"width :50px; background-color: ".BUTTON_ON_OUT.";\"
                             onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                             onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
               $xxx=$ActualQvantumPage-$ShowQvantumPage;
               $Pagexxx=$xxx;
               print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\" />";
               print "<input type=\"hidden\" value=\"".$F_Organisation."\" name=\"F_Organisation\" />";
               print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />";
               print "<input type=\"hidden\" value=\"".$Pagexxx."\" name=\"PageNo\" />";
               print "<input type=\"hidden\" value=\"".$xxx."\" name=\"ActualQvantumPage\" />";
               print "<input type=\"hidden\" value=\"".$Path."\" name=\"path\" />";
               print "<input type=\"hidden\" value=\"".$Category_ID."\" name=\"ID\" />";
             print "</form>";
             print "</td>";
             }
 //--------------------------------------------------------------------------------------

//podmienka zvysnych stranok------------------------------------------------------------
          if(($ActualQvantumPage/$ShowQvantumPage)==floor(($sql_array_adm[0]/$ItemsOnPage)/$ShowQvantumPage))
              { if($sql_array_adm[0]%$ItemsOnPage==0)
                    $ShowActualQvantumPage=((($sql_array_adm[0]/$ItemsOnPage)%$ShowQvantumPage));
                else
                    $ShowActualQvantumPage=((($sql_array_adm[0]/$ItemsOnPage)%$ShowQvantumPage)+1);
              }
          else
              {$ShowActualQvantumPage=$ShowQvantumPage;}
 //---------------------------------------------------------------------------------------
      for($i=$ActualQvantumPage;$i<$ActualQvantumPage+$ShowActualQvantumPage;$i++)
    {
      print "<form  action=\"order_management.php\" target=\"place\" method=\"post\">";
          print "<td>";
          $Xi=$i+1;
          if($PageNo==$i)
            print "<input type=\"submit\" value=\"".$Xi."\" name=\"PageNo\"  style=\"width :50px; background-color: ".BUTTON_ON_OVER.";\" />";
          else
            print "<input type=\"submit\" value=\"".$Xi."\" name=\"PageNo\" style=\"width :25px; background-color: ".BUTTON_ON_OUT.";\"
                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\"
                        />";
          print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\" />";
          print "<input type=\"hidden\" value=\"".$F_Organisation."\" name=\"F_Organisation\" />";
          print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />";
          print "<input type=\"hidden\" value=\"1\" name=\"PageQuanter\" />";
          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />";
          print "<input type=\"hidden\" value=\"".$Path."\" name=\"path\" />";
          print "<input type=\"hidden\" value=\"".$Category_ID."\" name=\"ID\" />";
          print "</form>";
          print "</td>";
    }

 //podmienka doprednej >>>> -----------------------------------------------------------
if(($sql_array_adm[0]/$ItemsOnPage) > ($ActualQvantumPage+$ShowQvantumPage)){
      print "<td>";
      print "<form  action=\"order_management.php\" target=\"place\" method=\"post\">";
      print "<input type=\"submit\" value=\">>>\"  style=\"width :50px; background-color: ".BUTTON_ON_OUT.";\"
              onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
              onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
      $xxx=$ActualQvantumPage+$ShowQvantumPage;
      $Pagexxx=$xxx;
      print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\" />";
      print "<input type=\"hidden\" value=\"".$F_Organisation."\" name=\"F_Organisation\" />";
      print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />";
      print "<input type=\"hidden\" value=\"".$Pagexxx."\" name=\"PageNo\" />";
      print "<input type=\"hidden\" value=\"".$xxx."\" name=\"ActualQvantumPage\" />";
      print "<input type=\"hidden\" value=\"".$Path."\" name=\"path\" />";
      print "<input type=\"hidden\" value=\"".$Category_ID."\" name=\"ID\" />";
    print "</form>";
    print "</td>";
    }
 //--------------------------------------------------------------------------------------
    print "</tr></table></center>";
    PrintLine();
    }while(false);

    print "<br>";
    //**************************************************************************
    //
    //Naplneneie obsahu stranky datami z databazy
    //
    //**************************************************************************
    //if($Category_ID==""){mysql_close(); break;}
        $From   = $PageNo*$ItemsOnPage;

        if ($F_Surname!="") $sql_psel= "SELECT * FROM order_heads WHERE OH_Surname LIKE '%".$F_Surname."%' ORDER BY ID DESC LIMIT ".$From.",".$ItemsOnPage;
            if ($F_Organisation!="") $sql_psel= "SELECT * FROM order_heads WHERE OH_Organisation LIKE '%".$F_Organisation."%'ORDER BY ID DESC LIMIT ".$From.",".$ItemsOnPage;
            if ($F_ICO!="") $sql_psel= "SELECT * FROM order_heads WHERE OH_ICO='".$F_ICO."'ORDER BY ID DESC LIMIT ".$From.",".$ItemsOnPage;
               if ($F_Surname=="" and $F_Organisation=="" and $F_ICO=="")
                $sql_psel=  "SELECT * FROM order_heads ORDER BY ID DESC LIMIT ".$From.",".$ItemsOnPage;

        $Product_source = mysql_query($sql_psel);
        $counter=0;
        while($sql_array_adm = mysql_fetch_object($Product_source))
        {
            $ShowAsDetails = is_roll($roll_show,$sql_array_adm->ID);
            if(!$ShowAsDetails)
            {
                    if(($counter%2))
                        print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"98%\" bgcolor=\"".TR_BACKGOUND_COLOR_2."\">";
                    else
                        print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"98%\" bgcolor=\"".TR_BACKGOUND_COLOR_1."\">";

                    //zobrazenie nazvu tovaru
                    print "<tr><td>";
                        if(($counter%2))
                            print "<table  border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" bgcolor=\"".TR_BACKGOUND_COLOR_2."\"><tr>";
                        else
                            print "<table  border=\"0\"cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" bgcolor=\"".TR_BACKGOUND_COLOR_1."\"><tr>";

                    print "<td align=\"left\">";
                      if($sql_array_adm->NO == '') $OrderNO = $sql_array_adm->ID;
                      else $OrderNO = date('Y',strtotime($sql_array_adm->Order_Create)).'/'.$sql_array_adm->NO;
                      print("<b><font color=\"black\">".$OrderNO."</font color></b>");
                      if  (Order_Is_Unread($sql_array_adm->ID)) print "[".O_NOVA."]";
                    print "</td>";
                    print "<td align=\"right\">";
                      if(Order_Is_Confirm($sql_array_adm->ID)) print "<b>[".O_POTVRDENA."]</b> ";
                      
                      print("
                        <b>
                            <font color=\"".TEXT_COLOR_ORDER."\">
                                (<a
                                    href=\"javascript:\"
                                    onClick=\"javascript:window.open('adm_order_show_user_detail.php?OID=".$sql_array_adm->ID."','o_user_detail','width=450px,height=240px,location=no,directories=no,menubar=no,resizeable=yes,status=no,toolbar=no,scrollbars=yes');\"
                                >
                                    ".$sql_array_adm->OH_Organisation." ".$sql_array_adm->OH_Name." ".$sql_array_adm->OH_Surname."
                                </a>)
                            </font color>
                        </b>"
                      );
                      print "(".date('d.m.Y',strtotime($sql_array_adm->Order_Create)).")";
                    print "</td>";
                    print "</tr></table></td>";

                    print "<td align=\"right\" width=\"63px\">";
                          print "<form action=\"order_management.php\" target=\"place\" method=\"post\">";
                            print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />";
                            print "<input type=\"hidden\" name=\"events\" value=\"show_order\" />";
                            print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                            print "<input type=\"hidden\" name=\"Ch_ID\" value=\"".$sql_array_adm->ID."\" />";
                            print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
                            print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\" />";
                            print "<input type=\"hidden\" value=\"".$F_Organisation."\" name=\"F_Organisation\" />";
                            print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />";
                            print "<input type=\"submit\" value=\"".O_ZOBRAZIT."\" style=\"width :60px; background-color: ".BUTTON_ON_OUT.";\"
                                onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                                onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
                          print "</form>";
                    print "</td>";

                    if(!Order_Is_Confirm($sql_array_adm->ID)){
                            print "<td align=\"right\" width=\"123px\">";
                                  print "<form action=\"order_management.php\" target=\"place\" method=\"post\">";
                                  print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />";
                                    print "<input type=\"hidden\" name=\"events\" value=\"confirm_order\" />";
                                    print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                                    print "<input type=\"hidden\" name=\"Ch_ID\" value=\"".$sql_array_adm->ID."\" />";
                                    print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
                                    print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\">";
                                    print "<input type=\"hidden\" value=\"".$F_Organisation."\" name=\"F_Organisation\" />";
                                    print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />";
                                    print "<input type=\"submit\" value=\"".O_POTVRDIT."\" style=\"width :120px; background-color: ".BUTTON_ON_OUT.";\"
                                        onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                                        onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
                                  print "</form>";
                            print "</td>";
                        }
                    else{
                              print "<td align=\"right\" width=\"123px\">";
                              print "<form action=\"order_management.php\" target=\"place\" method=\"post\">";
                              print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />";
                                print "<input type=\"hidden\" name=\"events\" value=\"confirm_order\" />";
                                print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                                print "<input type=\"hidden\" name=\"Ch_ID\" value=\"".$sql_array_adm->ID."\" />";
                                print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
                                print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\" />";
                                print "<input type=\"hidden\" value=\"".$F_Organisation."\" name=\"F_Organisation\" />";
                                print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />";
                                print "<input type=\"submit\" value=\"".O_ZRUS_POTVRD."\" style=\"width :120px; background-color: ".BUTTON_ON_OUT.";\"
                                    onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                                    onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
                              print "</form>";
                        print "</td>";
                    };

                    print "<td align=\"right\" width=\"43px\">";
                          print "<form action=\"order_management_print.php\" target=\"_Blank\" method=\"post\">";
                            print "<input type=\"hidden\" name=\"ID\" value=\"".$sql_array_adm->ID."\" />";
                            print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\">";
                            print "<input type=\"hidden\" value=\"".$F_Organisation."\" NAME=\"F_Organisation\" />";
                            print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />";
                            print "<input type=\"submit\" value=\"".O_TLAC."\" style=\"width :40px; background-color: ".BUTTON_ON_OUT.";\"
                                onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                                onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
                          print "</form>";
                    print "</td>";

                    print "<td align=\"right\" width=\"63px\">";
                          print "<form action=\"order_management.php\" target=\"place\" method=\"post\">";
                          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" NAME=\"ActualQvantumPage\" />";
                            print "<input type=\"hidden\" name=\"events\" value=\"delete_order\" />";
                            print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                            print "<input type=\"hidden\" name=\"Ch_ID\" value=\"".$sql_array_adm->ID."\" />";
                            print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
                            print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\" />";
                            print "<input type=\"hidden\" value=\"".$F_Organisation."\" name=\"F_Organisation\" />";
                            print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />";
                            print "<input type=\"submit\" value=\"".O_VYMAZ."\" style=\"width :60px; background-color: ".BUTTON_ON_OUT.";\"
                                onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                                onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
                          print "</form>";
                    print "</td></tr>";

            }
            else
            {
                if($ShowAsDetails){
                    if(($counter%2))
                        print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"98%\" bgcolor=\"".TR_BACKGOUND_COLOR_2."\">";
                    else
                        print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"98%\" bgcolor=\"".TR_BACKGOUND_COLOR_1."\">";

                    print "<tr><td>";


                    //***********zobrazenie mena, priezviska, nick, prav********
                    if(($counter%2))
                        print "<table  border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"".TR_BACKGOUND_COLOR_2."\" width=\"800px\" style=\"margin-left=5pt;\"> <caption><b>".P_TITULOK.": ".Get_Order_NO($sql_array_adm->ID)."</b> (".date('d.m.Y',strtotime($sql_array_adm->Order_Create)).")</caption>";
                    else
                        print "<table  border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"".TR_BACKGOUND_COLOR_1."\" width=\"800px\" style=\"margin-left=5pt;\"> <caption><b>".P_TITULOK.": ".Get_Order_NO($sql_array_adm->ID)."</b> (".date('d.m.Y',strtotime($sql_array_adm->Order_Create)).")</caption>";


                                //**********************************************************************
                                //zobrazenie udajov o dodavatelovi
                                //**********************************************************************
                                print "<tr><td valign=\"top\">";
                                    print ("<b><u>".O_DODAVATEL.":</u></b><br />");
                                                $file = fopen("address.txt", "r") or die (O_SUBOR_ERR."'address.txt'!");
                                                while (!feof($file)){
                                                        $file_row = fgets($file, 500);
                                                        print ($file_row. "<br />");
                                                }
                                print "</td>";
                                //**********************************************************************
                                //zobrazenie udajov o odberatelovi
                                //**********************************************************************
                                print "<td valign=\"top\">";
                                    print ("<b><u>".O_ODBERATEL.":</u></b><br />");
                                        //vyhladanie udajov v DB
                                        @$dbResult=mysql_query("SELECT * FROM order_heads WHERE ID=".$sql_array_adm->ID);
                                        if (!dbResult) {
                                            print O_VYHLADANIE_ERR." (1)";
                                            break;
                                        }
                                        $sql_array_User = mysql_fetch_object($dbResult);
                                        if ($sql_array_User->OH_Organisation!="")
                                            print "
                                                <a
                                                    href=\"javascript:\"
                                                    onClick=\"javascript:window.open('adm_order_show_user_detail.php?OID=".$sql_array_User->ID."','o_user_detail','width=450px,height=240px,location=no,directories=no,menubar=no,resizeable=yes,status=no,toolbar=no,scrollbars=yes');\"
                                                >
                                                    ".$sql_array_User->OH_Organisation."
                                                </a>
                                                <br />
                                            ";
                                        //print $sql_array_User->OH_Name." ".$sql_array_User->OH_Surname."<br />";
                                        print "
                                            <a
                                                href=\"javascript:\"
                                                onClick=\"javascript:window.open('adm_order_show_user_detail.php?OID=".$sql_array_User->ID."','o_user_detail','width=450px,height=240px,location=no,directories=no,menubar=no,resizeable=yes,status=no,toolbar=no,scrollbars=yes');\"
                                            >
                                                ".$sql_array_User->OH_Name." ".$sql_array_User->OH_Surname."
                                            </a>
                                            <br />
                                        ";
                                        print "
                                            <a
                                                href=\"javascript:\"
                                                onClick=\"javascript:window.open('adm_order_show_user_detail.php?OID=".$sql_array_User->ID."','o_user_detail','width=450px,height=240px,location=no,directories=no,menubar=no,resizeable=yes,status=no,toolbar=no,scrollbars=yes');\"
                                            >
                                                ".$sql_array_User->OH_Street."
                                            </a>
                                            <br />
                                        ";
                                        print "
                                            <a
                                                href=\"javascript:\"
                                                onClick=\"javascript:window.open('adm_order_show_user_detail.php?OID=".$sql_array_User->ID."','o_user_detail','width=450px,height=240px,location=no,directories=no,menubar=no,resizeable=yes,status=no,toolbar=no,scrollbars=yes');\"
                                            >
                                                ".$sql_array_User->OH_PostID." ".$sql_array_User->OH_City."
                                            </a>
                                            <br />
                                        ";
                                        if ($sql_array_User->OH_ICO!="")
                                            print O_ICO.": ".$sql_array_User->OH_ICO."<br />";
                                        if ($sql_array_User->OH_DIC!="")
                                            print O_DIC.": ".$sql_array_User->OH_DIC."<br />";
                                        //sposob dorucenia
//                                        switch($sql_array_User->OH_Delivery){
//                                            case 0: print "<br /><br />".O_DORUCENIE_1; break;
//                                            case 1: print "<br /><br />".O_DORUCENIE_2; break;
//                                            case 2: print "<br /><br />".O_DORUCENIE_3; break;
//                                        }
                                        //sposob dorucenia
                                        $_OrderService = new classOrderService();
                                        print "<br /><br />".INV_SPOSOB_DORUCENIA.":".$_OrderService->getDeliveryName($sql_array_User->OH_Delivery);
                                        print "<br />".INV_SPOSOB_PLATBY.":".$_OrderService->getPaymentName($sql_array_User->OH_Payment);
                                        $Order_text = $sql_array_User->OH_Text;
                                        mysql_free_result($dbResult);

                                print "</td></tr>";
                                //**********************************************************************
                                //zobrazenie tovaru
                                //**********************************************************************
                                print "<tr><td colspan=\"2\">";
                                    print ("<b><u>".O_FAKTURUJEME_VAM.":</u></b></br>");
                                print "</td></tr>";
                                print "<tr><td colspan=\"2\">";
                                print "<table width=\"100%\">";
                                if(PAYER_VAT=="YES")
                                    //**********************************************************************
                                    //platca DPH
                                    print "<tr><td><b>".O_PNE."</b></td><td><b>".O_KOD."</b></td><td><b>".O_POLOZKA."</b></td><td><b>".O_MJ."</b></td><td><b>".O_CENA_ZA_MJ."</b></td><td><b>".O_DPH."</b></td><td><b>".O_CENA_S_DPH."</b></td><td><b>".O_MNOZSTVO."</b></td><td><b>".O_SPOLU."</b></td></tr>";
                                    //**********************************************************************
                                    else
                                    //**********************************************************************
                                    //platca DPH
                                    print "<tr><td><b>".O_PNE."</b></td><td><b>".O_KOD."</b></td><td><b>".O_POLOZKA."</b></td><td><b>".O_MJ."</b></td><td><b>".O_CENA_ZA_MJ."</b></td><td><b>".O_MNOZSTVO."</b></td><td><b>".O_SPOLU."</b></td></tr>";
                                    //**********************************************************************
                                
                                
                        $sql_bin= "SELECT * FROM order_products WHERE OH_ID=".$sql_array_adm->ID;
                        $bin_source = mysql_query($sql_bin);
                        $TotalSum=0;
                        while ($sql_array_Prodct = mysql_fetch_object($bin_source))
                        {
                          		//urcenie ci sa produt nachadza v tabulke produktov
                          		if($sql_array_Prodct->OP_ID != "")
                          			$products_count = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM products WHERE ID=$sql_array_Prodct->OP_ID"));    
                          		else
                          			$products_count[0] = 0;
                          			
                                print "<tr>";

                                print "<td>";
                                    if(ProductIsReadyForExpedition($sql_array_Prodct->ID))
                                        $RTE_Button_Caption = O_ANO;
                                    else
                                        $RTE_Button_Caption = O_NIE;
                                    print "<form action=\"order_management.php\" target=\"place\" method=\"post\">";
                                        print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />";
                                        print "<input type=\"hidden\" name=\"events\" value=\"ready_product\" />";
                                        print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                                        print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
                                        print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\">";
                                        print "<input type=\"hidden\" value=\"".$F_Organisation."\" name=\"F_Organisation\" />";
                                        print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />";
                                        print "<input type=\"hidden\" value=\"".$sql_array_Prodct->ID."\" name=\"RTE_ID\" />";
                                        print "<input type=\"submit\" value=\"".$RTE_Button_Caption."\"
                                            style=\"width :40px; background-color: ".BUTTON_ON_OUT.";\"
                                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
                                    print "</form>";

                                print "</td>";

                                print "<td>";
									//zobrazenie produktu v objednavke
									if($products_count[0] < 1)
                                		print $sql_array_Prodct->OP_Code;
                                	else
										//odkaz na produkt v objednavke
	                                	print "
											<a href=\"javascript:\"
                                                onclick=\"OpenPage(".$sql_array_Prodct->OP_ID.", 1);\"
												target=\"oa_product_detail\">".$sql_array_Prodct->OP_Code."</a>
										";
                                print "</td>";
								print "<td>";
                                	//zobrazenie produktu v objednavke
									if($products_count[0] < 1)
                                		print $sql_array_Prodct->OP_Name;
                                	else
										//odkaz na produkt v objednavke
	                                	print "
											<a href=\"javascript:\"
                                                onclick=\"OpenPage(".$sql_array_Prodct->OP_ID.", 1);\"
												target=\"oa_product_detail\">".$sql_array_Prodct->OP_Name."</a>
										";
                                print "</td>";
                                print "<td>";
                                print $sql_array_Prodct->OP_UnitType;
                                print "</td>";
                                print "<td>";
                                print FormatItAsCurrency($sql_array_Prodct->OP_Price);
                                print "</td>";
                                
                                
                                if(PAYER_VAT=="YES"){
		                        //**********************************************************************
		                        //platca DPH
		                        print "<td>";
		                                print $sql_array_Prodct->OP_DPH;
		                        print "</td>";
		                        print "<td>";
		                                print FormatItAsCurrency(((($sql_array_Prodct->OP_DPH)/100)+1) * $sql_array_Prodct->OP_Price);
		                        print "</td>";
		                        //**********************************************************************
		                    }
                                
                                
                                print "<td>";
                                print $sql_array_Prodct->OP_Count;
                                print "</td>";
                                if(PAYER_VAT=="YES"){
		                        //**********************************************************************
		        				//platca DPH
                                	print "<td>";
                                	print FormatItAsCurrency(((($sql_array_Prodct->OP_DPH)/100)+1) * $sql_array_Prodct->OP_Price * $sql_array_Prodct->OP_Count);
                                	print "</td>";
                                }
                                else{
                                  	//neplatca DPH
                                	print "<td>";
                                	print FormatItAsCurrency($sql_array_Prodct->OP_Price * $sql_array_Prodct->OP_Count);
                                	print "</td>";
                                }
                                
								print "</tr>";
								
								if(PAYER_VAT=="YES")
			                        //**********************************************************************
			        				//platca DPH
	                                $TotalSum+=((($sql_array_Prodct->OP_DPH)/100)+1) * $sql_array_Prodct->OP_Price * $sql_array_Prodct->OP_Count;
	                            else
	                            	//neplatca DPH
	                            	$TotalSum+= $sql_array_Prodct->OP_Price * $sql_array_Prodct->OP_Count;
                        }


                                print "</table>";
                                print "</td></tr>";
                                //**********************************************************************
                                //zobrazenie celkovej sumy
                                //**********************************************************************
                                print "<tr><td colspan=\"3\" valign=\"right\">";

                                    print '<small>'.O_PNE_PRIPRAVENE_NA_EXPEDOVANIE.'</small><br /><br />'; //it is only info about function

                                	if(PAYER_VAT=="YES")
			                        	//**********************************************************************
			        					//platca DPH
                                    	print ("<b><u>".O_CELKOM.":".RoundIt($TotalSum)." ".O_MENA_S_DPH."</u></b><br />");
                                    else
                                    	//neplatca DPH
                                    	print ("<b><u>".O_CELKOM.":".RoundIt($TotalSum)." ".O_MENA."</u></b><br />");
                                print "</td></tr>";
                                
                                //doplnujuci text
						        if($Order_text!="")
							        print "
							        	<tr>
											<td colspan=\"2\">
												<br />
												<u><b>".O_DOPLNUJUCI_TEXT.": </b></u><br />
												$Order_text
											</td>
										</tr>
							        ";

                                print "</table>";


                    //print "</table>";
                    //**********************************************************

                    print "</td><tr>";

                    print "<tr><td>";
                    	print "<br />";
                    	print "<table><tr>";                        
                    
                                    if(!Order_Is_Confirm($sql_array_adm->ID)){
                                        print "<td align=\"right\" width=\"123px\">";
                                              print "<form action=\"order_management.php\" target=\"place\" method=\"post\">";
                                              print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />";
                                                print "<input type=\"hidden\" name=\"events\" value=\"confirm_order\" />";
                                                print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                                                print "<input type=\"hidden\" name=\"Ch_ID\" value=\"".$sql_array_adm->ID."\" />";
                                                print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
                                                print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\">";
                                                print "<input type=\"hidden\" value=\"".$F_Organisation."\" name=\"F_Organisation\" />";
                                                print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />";
                                                print "<input type=\"submit\" value=\"".O_POTVRDIT."\" style=\"width :120px; background-color: ".BUTTON_ON_OUT.";\"
                                                    onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                                                    onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
                                              print "</form>";
                                        print "</td>";
                                    }
                                    else{
                                          print "<td align=\"right\" width=\"123px\">";
                                          print "<form action=\"order_management.php\" target=\"place\" method=\"post\">";
                                          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />";
                                            print "<input type=\"hidden\" name=\"events\" value=\"confirm_order\" />";
                                            print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                                            print "<input type=\"hidden\" name=\"Ch_ID\" value=\"".$sql_array_adm->ID."\" />";
                                            print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
                                            print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\" />";
                                            print "<input type=\"hidden\" value=\"".$F_Organisation."\" name=\"F_Organisation\" />";
                                            print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />";
                                            print "<input type=\"submit\" value=\"".O_ZRUS_POTVRD."\" style=\"width :120px; background-color: ".BUTTON_ON_OUT.";\"
                                                onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                                                onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
                                          print "</form>";
                                    print "</td>";
                                    };
                    
		                    print "<td align=\"right\" width=\"43px\">";
		                          print "<form action=\"order_management_print.php\" target=\"_Blank\" method=\"post\">";
		                            print "<input type=\"hidden\" name=\"ID\" value=\"".$sql_array_adm->ID."\" />";
		                            print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\">";
		                            print "<input type=\"hidden\" value=\"".$F_Organisation."\" NAME=\"F_Organisation\" />";
		                            print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />";
		                            print "<input type=\"submit\" value=\"".O_TLAC."\" style=\"width :40px; background-color: ".BUTTON_ON_OUT.";\"
		                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
		                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
		                          print "</form>";
		                    print "</td>";
		                    
		                    print "<td align=\"right\" valign=\"bottom\" width=\"83px\">";
		                          print "<form action=\"order_management.php\" target=\"place\" method=\"post\">";
		                          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />";
		                            print "<input type=\"hidden\" name=\"events\" value=\"show_order\" />";
		                            print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
		                            print "<input type=\"hidden\" name=\"Ch_ID\" value=\"".$sql_array_adm->ID."\" />";
		                            print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
		                            print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\" />";
		                            print "<input type=\"hidden\" value=\"".$F_Organisation."\" name=\"F_Organisation\" />";
		                            print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />";
		                            print "<input type=\"submit\" value=\"".O_ZRUS_NAHLAD."\" style=\"width :120px; background-color: ".BUTTON_ON_OUT.";\"
		                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
		                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
		                          print "</form>";
		                    print "</td>";
                                    
                                    print "<td align=\"right\" width=\"63px\">";
                                          print "<form action=\"order_management.php\" target=\"place\" method=\"post\">";
                                          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" NAME=\"ActualQvantumPage\" />";
                                            print "<input type=\"hidden\" name=\"events\" value=\"delete_order\" />";
                                            print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                                            print "<input type=\"hidden\" name=\"Ch_ID\" value=\"".$sql_array_adm->ID."\" />";
                                            print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
                                            print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\" />";
                                            print "<input type=\"hidden\" value=\"".$F_Organisation."\" name=\"F_Organisation\" />";
                                            print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />";
                                            print "<input type=\"submit\" value=\"".O_VYMAZ."\" style=\"width :60px; background-color: ".BUTTON_ON_OUT.";\"
                                                onclick=\"top.scrollTo(0,0);\"
                                                onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\"
                                                onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
                                          print "</form>";
                                    print "</td>";
                    
                    
		                print "</tr></table>";
                    
                    print "</td></tr>";
                    print "</table>";
                };
            }
            print "</table>";
            $counter++;
        }


        print "<br>";
        PrintLine();

    //**************************************************************************
    //
    //Vytvorenie menu pre vyber zobrazovanej stranky (rozdelenie zobrazovane hotovaru) - ulozene dole
    //
    //**************************************************************************
    if ($F_Surname!="") $sql_psel= "SELECT COUNT(*) FROM order_heads WHERE OH_Surname LIKE '%".$F_Surname."%'";
    if ($F_Organisation!="") $sql_psel= "SELECT COUNT(*) FROM order_heads WHERE OH_Organisation LIKE '%".$F_Organisation."%'";
    if ($F_ICO!="") $sql_psel= "SELECT COUNT(*) FROM order_heads WHERE OH_ICO='".$F_ICO."'";
    if ($F_Surname=="" and $F_Organisation=="" and $F_ICO=="")
            $sql_psel= "SELECT COUNT(*) FROM order_heads";
    $sql_array_adm = mysql_fetch_row(mysql_query($sql_psel));
    do{
            if (($sql_array_adm[0]/$ItemsOnPage)<=1) break;
             print"<CENTER><table style=\"position:relative;  top:5px;\"><tr>";

// Podmienka prvej >>>> --------------------------------------------------------------------
      if(($sql_array_adm[0]/$ItemsOnPage>$ShowQvantumPage) and ($ActualQvantumPage-$ShowQvantumPage>=0)){
             print "<td>";
             print "<form  action=\"order_management.php\" target=\"place\" method=\"post\">";
             if($sql_array_adm[0]>$ShowQvantumPage)
               print "<input type=\"submit\" value=\"<<<\"  style=\"width :50px; background-color: ".BUTTON_ON_OUT.";\"
                             onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                             onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
               $xxx=$ActualQvantumPage-$ShowQvantumPage;
               $Pagexxx=$xxx;
               print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\" />";
               print "<input type=\"hidden\" value=\"".$F_Organisation."\" name=\"F_Organisation\" />";
               print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />";
               print "<input type=\"hidden\" value=\"".$Pagexxx."\" name=\"PageNo\" />";
               print "<input type=\"hidden\" value=\"".$xxx."\" name=\"ActualQvantumPage\" />";
               print "<input type=\"hidden\" value=\"".$Path."\" name=\"path\" />";
               print "<input type=\"hidden\" value=\"".$Category_ID."\" name=\"ID\" />";
             print "</form>";
             print "</td>";
             }
 //--------------------------------------------------------------------------------------

//podmienka zvysnych stranok------------------------------------------------------------
          if(($ActualQvantumPage/$ShowQvantumPage)==floor(($sql_array_adm[0]/$ItemsOnPage)/$ShowQvantumPage))
              { if($sql_array_adm[0]%$ItemsOnPage==0)
                    $ShowActualQvantumPage=((($sql_array_adm[0]/$ItemsOnPage)%$ShowQvantumPage));
                else
                    $ShowActualQvantumPage=((($sql_array_adm[0]/$ItemsOnPage)%$ShowQvantumPage)+1);
              }
          else
              {$ShowActualQvantumPage=$ShowQvantumPage;}
 //---------------------------------------------------------------------------------------
      for($i=$ActualQvantumPage;$i<$ActualQvantumPage+$ShowActualQvantumPage;$i++)
    {
      print "<form  action=\"order_management.php\" target=\"place\" method=\"post\">";
          print "<td>";
          $Xi=$i+1;
          if($PageNo==$i)
            print "<input type=\"submit\" value=\"".$Xi."\" name=\"PageNo\"  style=\"width :50px; background-color: ".BUTTON_ON_OVER.";\">";
          else
            print "<input type=\"submit\" value=\"".$Xi."\" name=\"PageNo\" style=\"width :25px; background-color: ".BUTTON_ON_OUT.";\"
                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\"
                        />";
          print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\">";
          print "<input type=\"hidden\" value=\"".$F_Organisation."\" name=\"F_Organisation\">";
          print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\">";
          print "<input type=\"hidden\" value=\"1\" name=\"PageQuanter\">";
          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\">";
          print "<input type=\"hidden\" value=\"".$Path."\" name=\"path\">";
          print "<input type=\"hidden\" value=\"".$Category_ID."\" name=\"ID\">";
          print "</form>";
          print "</td>";
    }

 //podmienka doprednej >>>> -----------------------------------------------------------
if(($sql_array_adm[0]/$ItemsOnPage) > ($ActualQvantumPage+$ShowQvantumPage)){
      print "<td>";
      print "<form  action=\"order_management.php\" target=\"place\" method=\"post\">";
      print "<input type=\"submit\" value=\">>>\"  style=\"width :50px; background-color: ".BUTTON_ON_OUT.";\"
              onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
              onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
      $xxx=$ActualQvantumPage+$ShowQvantumPage;
      $Pagexxx=$xxx;
      print "<input type=\"hidden\" value=\"".$F_Surname."\" name=\"F_Surname\" />";
      print "<input type=\"hidden\" value=\"".$F_Organisation."\" name=\"F_Organisation\" />";
      print "<input type=\"hidden\" value=\"".$F_ICO."\" name=\"F_ICO\" />";
      print "<input type=\"hidden\" value=\"".$Pagexxx."\" name=\"PageNo\" />";
      print "<input type=\"hidden\" value=\"".$xxx."\" name=\"ActualQvantumPage\" />";
      print "<input type=\"hidden\" value=\"".$Path."\" name=\"path\" />";
      print "<input type=\"hidden\" value=\"".$Category_ID."\" name=\"ID\" />";
    print "</form>";
    print "</td>";
    }
 //--------------------------------------------------------------------------------------
    print "</tr></table></center>";
            PrintLine();
    }while(false);

    mysql_close();
}
while(false)
?>


</body>
</html>
